﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Visa_calendar.aspx.cs" Inherits="FS.Web.BLL.Visa_info.Visa_calendar" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>    
    <link href="/Themes/Styles/Site.css" rel="stylesheet" type="text/css" />
    <link href="/Themes/Scripts/EasyUI/easyui.css" rel="stylesheet" type="text/css" />
    <link href="/Themes/Scripts/EasyUI/icon.css" rel="stylesheet" type="text/css" />
    <script src="/Themes/Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>    
    <script src="/Themes/Scripts/FunctionJS.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/EasyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="/Themes/Scripts/DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
        var editIndex = undefined;
        function endEditing() {
            if (editIndex == undefined) { return true }
            if ($('#dg').datagrid('validateRow', editIndex)) {
                var ed = $('#dg').datagrid('getEditor', { index: editIndex, field: 'workid' });
                var workname = $(ed.target).combobox('getText');
                $('#dg').datagrid('getRows')[editIndex]['workname'] = workname;
                $('#dg').datagrid('endEdit', editIndex);
                editIndex = undefined;
                return true;
            } else {
                return false;
            }
        }
        function onClickRow(index) {
            if (editIndex != index) {
                if (endEditing()) {
                    $('#dg').datagrid('selectRow', index)
							.datagrid('beginEdit', index);
                    editIndex = index;
                } else {
                    $('#dg').datagrid('selectRow', editIndex);
                }
            }
        }
        
        function accept() {
            if (endEditing()) {
                if ($('#dg').datagrid('getChanges').length) {
                    var updated = $('#dg').datagrid('getChanges', "updated");
                    
                    var effectRow = new Object();                    
                                 
                    if (updated.length) {
                        effectRow["updated"] = JSON.stringify(updated);
                    }
                    
                    //$.post("servlet/commit", effectRow, function (rsp) {
                        
                    //    if (rsp.status) {
                            
                    //        $.messager.alert("提示", "提交成功！");
                           
                    //        $dg.datagrid('acceptChanges');
                            
                    //    }
                        
                    //}, "JSON").error(function () {
                        
                    //    $.messager.alert("提示", "提交错误了！");
                        
                    //});
                    
                }

            }
        }
        function reject() {
            $('#dg').datagrid('rejectChanges');
            editIndex = undefined;
        }

        function loaddata() {
            var begdate = $('#begdate').val();
            var enddate = $('#enddate').val();
                        
            var parm = 'action=calendarlist&begdate=' + begdate + '&enddate=' + enddate;
            getAjax('EasySelect.ashx', parm, function (rs) {
                var V_JSON = rs;
                var json = eval("(" + V_JSON + ")");
                $('#dg').datagrid('loadData', json);
            });
        }       
	</script>     
</head>
<body>
    <form id="form1" runat="server">
    <div class="btnbartitle">
        <div>
            工作日历
        </div>
    </div>
    <div id="tb" style="height:auto">
        日期<input id="begdate" runat="server" type="text" class="txt" style="width:110px" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd' })" />
		至<input id="enddate" runat="server" type="text" class="txt" style="width:110px" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd' })" />
		
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search'"  onclick="loaddata()">查找</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save'"  onclick="accept()">保存</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-undo'" onclick="reject()"> 取消</a>       
	</div>
    <div class="div-body">
        <table id="dg" class="easyui-datagrid" title="系统工作日历信息" style="width:700px;height:auto"
			data-options="
				iconCls: 'icon-edit',
				singleSelect: true,
				toolbar: '#tb',
				url: null,
				method: 'get'
                ,onClickRow: onClickRow
			">
		    <thead>
			    <tr>
				    <th data-options="field:'id', hidden:true">id</th>
                    <th data-options="field:'workdate',width:80">日期</th>
				    <th data-options="field:'workid',width:60,
                            formatter:function(value,row){
							        return row.workname;
						        },
                            editor:{
							    type:'combobox',                                
							    options:{
								    valueField:'workid',
								    textField:'workname',
								    data: [{
			                            workid: 'W',
			                            workname: '平时'
		                                },{
			                                workid: 'R',
			                                workname: '周末'
		                                },{
			                                workid: 'H',
			                                workname: '节日'
		                                }]                              
							        }
						    }">类型</th>				    
			    </tr>
		    </thead>
	    </table>
    </div>
    </form>
</body>
</html>
